How to demonstrate the use of the local and global variables in PHP | PHP programs
We will demonstrate local and global variables with the same name and access the global variable from the scope of the local variable.
<?php
$NUM=10;
function test_fun()
{
$NUM=20;
printf("<br>Local NUM : %d",$NUM);
global $NUM;
printf("<br>Global NUM : %d",$NUM);
}
test_fun();
?>


